function getUserInfo() {
  axios.get('/my/user/userinfo', {
    headers: {
      Authorization: localStorage.getItem('token')
    }
  }).then(res => {
    let { nickname, user_pic, username } = res.data.data
    let name = nickname || username
    $('.username').text(name)

    if (user_pic) {
      $('.layui-nav-img').attr('src', user_pic).show();
      $('.user-avatar').hide();
    } else {
      let first = name.substring(0, 1).toUpperCase
      $('.user-avatar').text(first).css('display', 'inline-block')
    }
  })
}
getUserInfo()

$('#logout').on('click', function () {
  layer.confirm('确定要抛弃我么?', function () {
    localStorage.removeItem('token')
    location.href = './login.html'
    layer.close(index)
  })
})